package com.stone.databinding.ui;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableInt;

import android.os.Bundle;
import android.view.View;

import com.stone.databinding.R;
import com.stone.databinding.data.ObservableFieldProfile;
import com.stone.databinding.databinding.ActivityObservableFieldBinding;

public class ObservableFieldActivity extends AppCompatActivity {
    private ObservableFieldProfile mUser;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityObservableFieldBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_observable_field);
        mUser = new ObservableFieldProfile("Dan", "Vie", new ObservableInt(0));
        binding.setUser(mUser);
    }

    public void onLike(View view) {
        if (mUser != null) {
            mUser.setLikesNum(mUser.getLikesNum().get() + 1);
        }
    }
}
